import Vue from 'vue'
import Router from 'vue-router'
//普通用法，一次性全加载。
// import Hello from '@/pages/Hello'
// import basic from '@/pages/basic'
// import advance from '@/pages/advanced'
// const Foo = {
//   template: '<div>foo</div>'
// }
Vue.use(Router)
//进阶用法，懒加载。(有请求才加载，使用场景最多)
const Hello = resolve => {
  require.ensure(['@/pages/Hello.vue'],()=>{
    resolve(require('@/pages/Hello.vue'))
  })
}
const basic = resolve => {
  require.ensure(['@/pages/basic.vue'],()=>{
    resolve(require('@/pages/basic.vue'))
  })
}
const transition = resolve => {
  require.ensure(['@/pages/transition.vue'],()=>{
    resolve(require('@/pages/transition.vue'))
  })
}
const todolist = resolve => {
  require.ensure(['@/pages/todolist.vue'],()=>{
    resolve(require('@/pages/todolist.vue'))
  })
}
const vuex = resolve => {
  require.ensure(['@/pages/vuex.vue'],()=>{
    resolve(require('@/pages/vuex.vue'))
  })
}
const advance = resolve =>{
  require.ensure(['@/pages/advance.vue'],()=>{
    resolve(require('@/pages/advance.vue'))
  })
}
export default new Router({
  mode: 'history',
  routes: [
    {
      path: '',
      name: 'Hello',
      component: Hello
    },
    {
    	path:'/basic',
    	component:basic
    },
    {
    	path:'/transition',
    	component:transition
    },
    {
    	path:'/advance',
    	component:advance
    },
    {
      path:'/todolist',
      component:todolist
      // component: resolve => require(['./page/linkParamsQuestion.vue'], resolve)
    },
    {
      path:'/vuex',
      component:vuex
    }
  ]
})
